
package com.noah.project

import org.junit.Test
import org.junit.runner.RunWith
import org.slf4j.LoggerFactory
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import java.util.Calendar




/**
 * Created by Wiki on 2018/5/25.
 */

@RunWith(SpringRunner::class)
@SpringBootTest
class LoggerTest {
    var logger = LoggerFactory.getLogger(LoggerTest::class.java)
    @Test
    fun test() {

        logger.info("    "+getWeekNumberOfMonth(1530374400000L))
        logger.warn("ImWiki")
        logger.error("ImWiki")
        logger.debug("ImWiki")
//        for (i in 0..10000){
//            logger.error("i = $i")
//            logger.info("i = $i")
//        }

    }

    fun getWeekNumberOfMonth(time: Long): Int {
        val calendar = Calendar.getInstance()//这一句必须要设置，否则美国认为第一天是周日，而我国认为是周一，对计算当期日期是第几周会有错误
        calendar.firstDayOfWeek = Calendar.MONDAY // 设置每周的第一天为星期一
        calendar.timeInMillis = time
        return calendar.get(Calendar.WEEK_OF_MONTH)
    }
}
